from django.template.defaultfilters import register


@register.filter(is_safe=False)
def div_arg(value, arg):
    """自定义除法过滤器"""
    try:
        return int(value) // int(arg)
    except (ValueError, TypeError):
        try:
            return value // arg
        except Exception:
            return ''
